package com.mew.slots.core.game.tjcs;

import com.mew.common.entity.game.WinFree;
import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.bo.GameSession;
import com.mew.slots.core.common.handler.AbstractBetHandler;
import com.mew.slots.core.common.handler.SlotsHandler;
import com.mew.slots.core.common.messge.response.SlotsBonusPlayResponseMessage;
import com.mew.slots.core.common.messge.response.SlotsPlayResponseMessage;
import com.mew.slots.core.common.utils.SlotsGameUtil;
import com.mew.slots.core.common.vo.StrategyGameVO;
import com.mew.slots.core.game.tjcs.roller.TjcsIli;
import com.mew.slots.core.game.tjcs.roller.TjcsXml;
import com.mew.slots.core.game.tjcs.service.TjcsBonusService;
import com.mew.slots.core.game.tjcs.service.TjcsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author King.Song
 * @Date 2020/11/9 0009
 **/
@Service
@SlotsHandler(value = "TJCS")
@Slf4j
public class TjcsHandler extends AbstractBetHandler {

    private TjcsService service = new TjcsService();
    private TjcsBonusService bonusService = new TjcsBonusService();
    @Override
    public void specialCheck(StrategyGameVO gameVO, GameSession userVO) {
        WinFree winfree=gameVO.getWinFree();
        if(winfree.getFrees()>0&&winfree.getFreeNumber()==0){
            gameVO.setStat(ResponseCode.WinFreeValidError.code());
        }
    }

    @Override
    public SlotsPlayResponseMessage play(StrategyGameVO gameVO, GameSession userVO) {

        return service.Ready(gameVO);
    }

    @Override
    public SlotsBonusPlayResponseMessage playBonus(StrategyGameVO gameVO, GameSession userVO) {
        return bonusService.play(gameVO);
    }

    @Override
    public void readRoller() throws Exception{
        TjcsIli.getInstance().init();
    }

    public static void main(String[] args) throws Exception {
        TjcsHandler handler=new TjcsHandler();
        handler.readRoller();
        StrategyGameVO vo = SlotsGameUtil.buildTestStrategyGameVO();
        vo.setLineNumber(50);
        SlotsPlayResponseMessage message = handler.play( vo,null);
        System.out.println(message);
    }
}
